---
title: What is Storage?
sidebarTitle: Overview
description: Enable your Agents to store session history, memories, and more.
---

**Storage** adds persistence to your Agents, allowing them to remember previous messages, user memories, and more.

It works by equipping your Agents with a database that they will use to store and retrieve:
- [Sessions](/concepts/agents/sessions)
- [User Memories](/concepts/agents/memory)

In addition this DB is used to store [knowledge](/concepts/knowledge/content_db) and [evals](/concepts/evals/overview).

<Tip>
**When should I use Storage on my Agents?**

Agents are ephemeral by default. They won't remember previous conversations.

But in production environments, you will often need to continue the same session across multiple requests. Storage is the way to persist the session history and state in a database, enabling us to pick up where we left off.

Storage also lets us inspect and evaluate Agent sessions, extract few-shot examples and build internal monitoring tools. In general, it lets you **keep track of the data**, to build better Agents.
</Tip>

## Adding storage to your Agent

To enable session persistence on your Agent, just setup a database and provide it to the Agent:

```python
from agno.agent import Agent
from agno.db.sqlite import SQLiteDb

# Setup your database
db = SQLiteDb(id="my_agent_db", db_file="agno.db")

# Initialize your Agent passing the database
agent = Agent(db=db)
```
<Note>
It's recommended to add `id` for better management and easier identification of database. You can add it to your database configuration like this:
</Note>

### Adding session history to the context

Agents with a `db` will persist their [sessions](/concepts/agents/sessions) in the database. You can also automatically add the persisted history to the context, effectively enabling Agents to persist sessions:

```python
from agno.agent import Agent
from agno.db.sqlite import SQLiteDb

# Setup your database
db = SQLiteDb(db_file="agno.db")

# Setup your Agent with the database and add the session history to the context
agent = Agent(
    db=db,
    add_history_to_context=True, # Automatically add the persisted session history to the context
    num_history_runs=3, # Specify how many messages to add to the context
)
```

### Where are sessions stored?

By default, sessions are stored in the `agno_sessions` table of the database.

If the table or collection doesn't exist, it is created automatically when first storing a session.

You can specify where the sessions are stored exactly using the `session_table` parameter:

```python
from agno.agent import Agent
from agno.db.postgres import PostgresDb

# Setup your database
db = PostgresDb(
    db_url="postgresql://user:password@localhost:5432/my_database",
    session_table="my_session_table", # Specify the table to store sessions
)

# Setup your Agent with the database
agent = Agent(db=db)

# Run the Agent. This will store a session in our "my_session_table"
agent.print_response("What is the capital of France?")
```

## Retrieving sessions

You can manually retrieve stored sessions using the `get_session` method. This also works for `Teams` and `Workflows`:

```python
from agno.agent import Agent
from agno.db.sqlite import SQLiteDb

# Setup your database
db = SQLiteDb(db_file="agno.db")

# Setup your Agent with the database
agent = Agent(db=db)

# Run the Agent, effectively creating and persisting a session
agent.print_response("What is the capital of France?", session_id="123")

# Retrieve our freshly created session
session_history = agent.get_session(session_id="123")
```

## Benefits of using session storage

When building production-ready agentic applications, storage will often be a very important feature. This is because it enables to:

- Continue a session: retrieve previous messages and enable users to pick up a conversation where they left off.
- Keep a record of sessions: enable users to inspect their past conversations.
- Data ownership: keeping sessions in your own database gives you full control over the data.

<Warning>
  Storage is a critical part of your Agentic infrastructure. We recommend to
  never offload it to a third-party service. You should almost always use your
  own storage layer for your Agents.
</Warning>

## Storage for Teams and Workflows

Storage also works with Teams and Workflows, providing persistent memory for your more complex agentic applications.

Similarly to Agents, you simply need to provide your Team or Workflow with a database for sessions to be persisted:

```python
from agno.team import Team
from agno.workflow import Workflow
from agno.db.sqlite import SQLiteDb

# Setup your database
db = SQLiteDb(db_file="agno.db")

# Setup your Team
team = Team(db=db, ...)

# Setup your Workflow
workflow = Workflow(db=db, ...)
```

<Note>
  Learn more about [Teams](/concepts/teams/overview) and
  [Workflows](/concepts/workflows/overview), Agno abstractions to build
  multi-agent systems.
</Note>

## Supported databases

This is the list of the databases we currently support:

<CardGroup cols={3}>
  <Card
    title="DynamoDB"
    icon="database"
    iconType="duotone"
    href="/concepts/db/dynamodb"
  >
    Amazon's NoSQL database service
  </Card>
  <Card
    title="FireStore"
    icon="database"
    iconType="duotone"
    href="/concepts/db/firestore"
  >
    Google's NoSQL document database
  </Card>
  <Card
    title="JSON"
    icon="file-code"
    iconType="duotone"
    href="/concepts/db/json"
  >
    Simple file-based JSON storage
  </Card>
  <Card
    title="JSON on GCS"
    icon="cloud"
    iconType="duotone"
    href="/concepts/db/gcs"
  >
    JSON storage on Google Cloud Storage
  </Card>
  <Card
    title="MongoDB"
    icon="database"
    iconType="duotone"
    href="/concepts/db/mongodb"
  >
    Popular NoSQL document database
  </Card>
  <Card
    title="MySQL"
    icon="database"
    iconType="duotone"
    href="/concepts/db/mysql"
  >
    Widely-used relational database
  </Card>
  <Card
    title="Neon"
    icon="database"
    iconType="duotone"
    href="/concepts/db/neon"
  >
    Serverless PostgreSQL platform
  </Card>
  <Card
    title="PostgreSQL"
    icon="database"
    iconType="duotone"
    href="/concepts/db/postgres"
  >
    Advanced open-source relational database
  </Card>
  <Card
    title="Redis"
    icon="database"
    iconType="duotone"
    href="/concepts/db/redis"
  >
    In-memory data structure store
  </Card>
  <Card
    title="SingleStore"
    icon="database"
    iconType="duotone"
    href="/concepts/db/singlestore"
  >
    Real-time analytics database
  </Card>
  <Card
    title="SQLite"
    icon="database"
    iconType="duotone"
    href="/concepts/db/sqlite"
  >
    Lightweight embedded database
  </Card>
  <Card
    title="Supabase"
    icon="database"
    iconType="duotone"
    href="/concepts/db/supabase"
  >
    Open source Firebase alternative
  </Card>
</CardGroup>

<Note>
We also support using an [In-Memory](/concepts/db/in_memory) database. This is not recommended for production, but perfect for demos and testing.
</Note>

You can see a detailed list of [examples](/examples/concepts/db) for all supported databases.
